<?php
	session_start();
?>
<table id="dghang_u_table" align="center" width="400px">
<tr>
	<td width="125px" align="right">ID: </td>
    <td><input type="text" id="id" value="" size="10" disabled="disabled" /></td>
</tr>
<tr>
	<td align="right">Hàng hóa: </td>
    <td>
    	<div id="idhang"></div>
    	<input type="hidden" id="idhang1" value=""/>
    </td>
</tr>
<tr>
	<td align="right">Ngày hiệu lực: </td>
    <td>
    	<input type="text" id="ngay" size="10" maxlength="10" value="<?php echo date("d-m-Y");?>" />
        <input type="text" id="gio" size="5" maxlength="5" value="<?php echo date("H:i");?>" />
    </td>
</tr>
<tr>
	<td align="right">Đơn giá: </td>
    <td><input type="text" id="dongia" alt="decimal-us"/></td>
</tr>
<tr>
	<td align="right">Đơn vị tính: </td>
    <td>
    	<div id="iddvthang"></div>
    	<input type="hidden" id="iddvthang1" value=""/>
    </td>
</tr>
<tr>
	<td align="right">Sử dụng:  </td>
    <td>
        <select id="chophep">
        	<option value="1">Cho phép</option>
            <option value="0">Cấm</option>
        </select>
    </td>
</tr>
<tr>
	<td align="right">Ngày tạo: </td>
    <td><input id="ngaytao" type="text" value="<?php echo date("Y-n-j G:i:s");?>" disabled="disabled" /></td>
</tr>
<tr>
	<td align="right">Người tạo: </td>
    <td><input id="un" type="text" value="<?php echo $_SESSION["un"];?>" disabled="disabled" /></td>
</tr>
</table>
<script language="javascript" type="text/javascript">
	$("#dghang_u_table #ngay").setMask({
		mask:"39-19-2099",
		onInvalid:function(c,nKey){
			msgbox("fail","ký tự '"+c+"' không hợp lệ !.");
			$(this).css("background","red");
		},
		onValid: function(c,nKey){
			$(this).css("background","#40FF3F");
		},
		onOverflow: function(c,nKey){
			msgbox("fail","Quá số ký tự cho  phép !");
			$(this).css("background","red");
		}
	});

	$("#dghang_u_table #gio").setMask({
		mask:"29:69",
		onInvalid:function(c,nKey){
			msgbox("fail","ký tự '"+c+"' không hợp lệ !.");
			$(this).css("background","red");
		},
		onValid: function(c,nKey){
			$(this).css("background","#40FF3F");
		},
		onOverflow: function(c,nKey){
			msgbox("fail","Quá số ký tự cho  phép !");
			$(this).css("background","red");
		}
	});

	$("#dghang_u_table #iddvthang").flexbox("modules/dvthang/json.php?idhang=<?php echo $_GET["idhang"];?>",{
			resultTemplate: "<tr><td>{id}</td><td>{name}</td></tr>",
			watermark: "Chọn đơn vị tính",
			paging: {pageSize:5},
			allowInput: true,
			width: 200,
			onSelect: function() {
				$("#dghang_u_table #iddvthang1").attr("value",this.getAttribute("hiddenValue"));
		}
	});

	$("#dghang_u_table #dongia").setMask();
	$("#dghang_u_table #ngay").select();
	$("#dghang_u_table #gio").select();
	$("#dghang_u_table #ngay").focus();
</script>
